home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1994 / MacHack 1994.toast / MacHack™ 1987-1994 / MacHack™ '93 / Hacks '93 / SCSIPatch / Libraries / patchlib.a next >
Text File  |  1992-06-09  |  5KB  |  202 lines

  1. ; ===========================================
  2. ; Copyright Paul Baxter
  3. ; ===========================================
  4.     Include    'Traps.a'
  5.     Include  'SCSIEqu.a'
  6.     Include  'SysErr.a'
  7.  
  8.     CASE OFF
  9.  
  10. SCSITRAPNUM    EQU    $A815
  11.  
  12. ; ===========================================
  13. ; routine selectors
  14. ; ===========================================
  15. start_rec    EQU    512
  16. stop_rec        EQU    513
  17. clear_rec    EQU    514
  18. send_rec        EQU    515
  19.  
  20.                 MACRO
  21.                 _SCSIStartRecord
  22.                 MOVE        #start_rec,-(SP)
  23.                 _SCSIDispatch
  24.                 ENDM
  25.                 
  26.                 MACRO
  27.                 _SCSIStopRecord
  28.                 MOVE        #stop_rec,-(SP)
  29.                 _SCSIDispatch
  30.                 ENDM
  31.                 
  32.                 MACRO
  33.                 _SCSIInitRecord
  34.                 MOVE        #clear_rec,-(SP)
  35.                 _SCSIDispatch
  36.                 ENDM
  37.                 
  38.                 MACRO
  39.                 _SCSISendRecord
  40.                 MOVE        #send_rec,-(SP)
  41.                 _SCSIDispatch
  42.                 ENDM
  43.  
  44. SCSIPatchAvail PROC EXPORT 
  45.  
  46. StackFrame  RECORD    {A6Link},DECR    ; build a stack frame record
  47. Result        DS.W    1                        ; function's result returned to caller
  48. RetAddr         DS.L    1                        ; place holder for return address
  49. A6Link        DS.L    1                        ; place holder for A6 link
  50. LocalSize     EQU     *                        ; size of all the local variables
  51.                 ENDR
  52.  
  53.                 WITH        StackFrame        ; cover our local stack frame
  54.                 LINK        A6,#LocalSize    ; allocate our local stack frame
  55.                 MOVE.W    #SCSITRAPNUM,D0; _SCSIDispatch Trap
  56.                 _GetTrapAddress newTool
  57.                 MOVE.W    #-1,D0
  58.                 SUBA.L    #16,A0
  59.     
  60.                 CMPI.L    #'PTCH',(A0)
  61.                 BNE.S        @trap_not_available
  62.  
  63.                 ADDQ.L    #4,A0
  64.                 CMPI.L    #'SCSI',(A0)
  65.                 BEQ.S        @trap_available
  66.                 
  67. @trap_not_available
  68.                 MOVEQ.L    #0,D0
  69. @trap_available
  70.                 MOVE.W    D0,Result(A6)
  71.                 UNLK    A6                        ; destroy the link
  72.                 MOVEA.L    (SP)+,A0            ; pull off the return address
  73.                 JMP        (A0)                ; return to the caller
  74. ENDP
  75.  
  76. SCSIStartRecord PROC EXPORT 
  77.  
  78. StackFrame  RECORD    {A6Link},DECR    ; build a stack frame record
  79. Result        DS.W    1                        ; function's result returned to caller
  80. RetAddr         DS.L    1                        ; place holder for return address
  81. A6Link        DS.L    1                        ; place holder for A6 link
  82. LocalSize     EQU     *                        ; size of all the local variables
  83.                 ENDR
  84.  
  85.                 WITH        StackFrame        ; cover our local stack frame
  86.                 LINK        A6,#LocalSize    ; allocate our local stack frame
  87.                 
  88.                 SUBQ.L    #2,SP                ; First see if our Patch is installed
  89.                 BSR        SCSIPatchAvail
  90.                 MOVE.W    (SP)+,D1
  91.                 MOVE.W    #unimpErr,D0
  92.                 TST.W        D1
  93.                 BEQ.S        @exit                ; It's not here
  94.  
  95.                 SUBQ.L    #2,SP
  96.                 _SCSIStartRecord
  97.                 MOVE.W    (SP)+,D0
  98. @exit
  99.                 MOVE.W    D0,Result(A6)
  100.                 UNLK    A6                        ; destroy the link
  101.                 MOVEA.L    (SP)+,A0            ; pull off the return address
  102.                 JMP        (A0)                ; return to the caller
  103. ENDP
  104.  
  105. SCSIStopRecord PROC EXPORT
  106.  
  107. StackFrame  RECORD    {A6Link},DECR    ; build a stack frame record
  108. Result        DS.W    1                        ; function's result returned to caller
  109. RetAddr         DS.L    1                        ; place holder for return address
  110. A6Link        DS.L    1                        ; place holder for A6 link
  111. LocalSize     EQU     *                        ; size of all the local variables
  112.                 ENDR
  113.  
  114.                 WITH        StackFrame        ; cover our local stack frame
  115.                 LINK        A6,#LocalSize    ; allocate our local stack frame
  116.  
  117.                 SUBQ.L    #2,SP                ; First see if our Patch is installed
  118.                 BSR        SCSIPatchAvail
  119.                 MOVE.W    (SP)+,D1
  120.                 MOVE.W    #unimpErr,D0
  121.                 TST.W        D1
  122.                 BEQ.S        @exit                ; It's not here
  123.  
  124.                 SUBQ.L    #2,SP
  125.                 _SCSIStopRecord
  126.                 MOVE.W    (SP)+,D0
  127. @exit
  128.                 MOVE.W    D0,Result(A6)
  129.                 UNLK    A6                        ; destroy the link
  130.                 MOVEA.L    (SP)+,A0            ; pull off the return address
  131.                 JMP        (A0)                ; return to the caller
  132. ENDP
  133.  
  134. SCSIInitRecord PROC EXPORT
  135.  
  136. StackFrame  RECORD    {A6Link},DECR    ; build a stack frame record
  137. Result        DS.W    1                        ; function's result returned to caller
  138. RetAddr         DS.L    1                        ; place holder for return address
  139. A6Link        DS.L    1                        ; place holder for A6 link
  140. LocalSize     EQU     *                        ; size of all the local variables
  141.                 ENDR
  142.  
  143.                 WITH        StackFrame        ; cover our local stack frame
  144.                 LINK        A6,#LocalSize    ; allocate our local stack frame
  145.  
  146.                 SUBQ.L    #2,SP                ; First see if our Patch is installed
  147.                 BSR        SCSIPatchAvail
  148.                 MOVE.W    (SP)+,D1
  149.                 MOVE.W    #unimpErr,D0
  150.                 TST.W        D1
  151.                 BEQ.S        @exit                ; It's not here
  152.  
  153.                 SUBQ.L    #2,SP
  154.                 _SCSIInitRecord
  155.                 MOVE.W    (SP)+,D0
  156. @exit
  157.                 MOVE.W    D0,Result(A6)
  158.                 UNLK    A6                        ; destroy the link
  159.                 MOVEA.L    (SP)+,A0            ; pull off the return address
  160.                 JMP        (A0)                ; return to the caller
  161. ENDP
  162.  
  163.  
  164. SCSISendRecord PROC EXPORT 
  165.  
  166. StackFrame  RECORD    {A6Link},DECR    ; build a stack frame record
  167. Result        DS.W    1                        ; function's result returned to caller
  168. ParamBegin    EQU    *                        ; start parameters after this point
  169. Buffer        DS.L    1                        ; the first parameter on the stack
  170. Count            DS.L    1                        ; the second parameter on the stack
  171. ParamSize    EQU    ParamBegin-*        ; size of all the passed parameters
  172. RetAddr         DS.L    1                        ; place holder for return address
  173. A6Link        DS.L    1                        ; place holder for A6 link
  174. LocalSize     EQU     *                        ; size of all the local variables
  175.                 ENDR
  176.  
  177.                 WITH        StackFrame        ; cover our local stack frame
  178.                 LINK        A6,#LocalSize    ; allocate our local stack frame
  179.  
  180.                 SUBQ.L    #2,SP                ; First see if our Patch is installed
  181.                 BSR        SCSIPatchAvail
  182.                 MOVE.W    (SP)+,D1
  183.                 MOVE.W    #unimpErr,D0
  184.                 TST.W        D1
  185.                 BEQ.S        @exit                ; It's not here
  186.  
  187.                 SUBQ.L    #2,SP
  188.                 MOVE.L    Buffer(A6),-(SP)
  189.                 MOVE.L    Count(A6),-(SP)
  190.                 _SCSISendRecord
  191.                 MOVE.W    (SP)+,D0
  192. @exit
  193.                 MOVE.W    D0,Result(A6)
  194.                 UNLK    A6                        ; destroy the link
  195.                 MOVEA.L    (SP)+,A0            ; pull off the return address
  196.                 ADDQ.L    #ParamSize,SP    ; strip all of the caller's parameters
  197.                 JMP        (A0)                ; return to the caller
  198. ENDP
  199.                 End
  200.  
  201. asm "{Active}" -o "{Active}.o"
  202.